package com.baomidou.wechat.mp.apistore.actuator;

import org.apache.commons.lang.StringUtils;

import com.alibaba.fastjson.JSON;
import com.baomidou.wechat.mp.apistore.vo.MobileVo;

/**
 * 手机号码归属地  API 执行 Actuator
 */
public class MobileActuator extends ApiStoreActuator<MobileVo> {
	private static String API_IP = "showapi_open_bus/mobile/find?num=%s";
	private String num;

	public static void main(String[] args) {
		ApiStoreActuator<MobileVo> actuator = new MobileActuator("13681527718");
		System.out.println(actuator.execute().toString());
	}

	protected MobileActuator() {
	}

	public MobileActuator(String num) {
		this.num = num;
	}

	@Override
	public MobileVo execute() {
		String json = executeHttpGet(null, API_IP, getNum());
		if (StringUtils.isNotBlank(json)) {
			String body = JSON.parseObject(json).getString("showapi_res_body");
			if (StringUtils.isNotBlank(body)) {
				return JSON.parseObject(body, MobileVo.class);
			}
		}
		return null;
	}

	public String getNum() {
		return num;
	}

	public void setNum(String num) {
		this.num = num;
	}

}
